package com.allianz.webapps.controllers;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.allianz.webapps.https.interfaces.type001.pojo.User;
import com.allianz.webapps.https.interfaces.util.ObjectUtil;
import com.allianz.webapps.quopojo.QuoCreateModel;
import com.fasterxml.jackson.databind.ObjectMapper;

//http://localhost:8080/pad_marketing/main/quoCreate.action

@Controller
@RequestMapping(value="main")
public class QuoCreate {

	@Autowired
	private ObjectMapper objectMapper;
	@Autowired
	private ObjectUtil objectUtil;
	
	@RequestMapping(value="quoCreate")
	@ResponseBody
	public String quoCreate(@RequestParam(value="jsonParam") String jsonParam,HttpServletRequest request,HttpServletResponse response)
			throws Exception{
		QuoCreateModel obj=objectMapper.readValue(jsonParam,QuoCreateModel.class);
		User user=(User)request.getSession().getAttribute("username");
		obj.setUser(user);
		String body=objectUtil.requestParam(obj, "quo.create");
		return body;
	}
	
}
